import Vue from 'vue'
import App from './App'
import router from './router'
//导入全局样式表
import './assets/css/global.css'
import './plugin/element'
import './assets/fonts/iconfont.css'

// require styles
import 'quill/dist/quill.core.css'
import 'quill/dist/quill.snow.css'
import 'quill/dist/quill.bubble.css'

import TreeTable from 'vue-table-with-tree-grid'
import VueQuillEditor from 'vue-quill-editor'
//import moment from 'moment'

Vue.config.productionTip = false

Vue.component("tree-table",TreeTable)
Vue.use(VueQuillEditor)

import axios from 'axios'
axios.defaults.baseURL = 'http://127.0.0.1:8888/api/private/v1'
//设置请求拦截器，为每一个有请求权限的API操作授权
axios.interceptors.request.use(config=>{
   config.headers.Authorization = window.sessionStorage.getItem('token')
  //在最后必须return config
  return config
})
Vue.prototype.axios = axios
//Vue.prototype.$moment = moment
Vue.filter('dateFormat',function(value){
  const dt = new Date(value)

  const y = dt.getFullYear()
  //padStart第一个参数为总长度，第二个参数表示不足两位补0
  const m = (dt.getMonth() + 1 + '').padStart(2, '0')
  const d = (dt.getDate() + '').padStart(2,'0')
  const hh = (dt.getHours()+'').padStart(2,'0')
  const mm = (dt.getMinutes() + '').padStart(2,'0')
  const ss = (dt.getSeconds()+ '').padStart(2,'0')

  //`yyyy-mm-dd hh:mm:ss`要替换成定义的哪个
  return `${y}-${m}-${d} ${hh}:${mm}:${ss}`
})





new Vue({
  el:'#app',
  router,
  render: h => h(App),
}).$mount('#app')


